if ($.fn.pagination){
	$.fn.pagination.defaults.beforePageText = 'Page';
	$.fn.pagination.defaults.afterPageText = 'of {pages}';
	$.fn.pagination.defaults.displayMsg = 'Displaying {from} to {to} of {total} items';
}
if ($.fn.datagrid){
	$.fn.datagrid.defaults.loadMsg = 'Processing, please wait ...';
}
if ($.messager){
	$.messager.defaults.ok = 'Ok';
	$.messager.defaults.cancel = 'Cancel';
}
//validator:注意英文暂时不加idcard；
var allRules = {
	"required":{
		"regex":"none",
		"alertText":"* 非空选项.",
		"alertTextCheckboxMultiple":"* 请选择一个单选框.",
		"alertTextCheckboxe":"* 请选择一个复选框."},
	"length":{
		"regex":"none",
		"alertText":"* 长度必须在 ",
		"alertText2":" 至 ",
		"alertText3": " 之间."},
	"telephone":{
		"regex":"/^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/",
		"alertText":"* 请输入有效的电话号码,如:010-29292929."},
	"mobilephone":{
		"regex":"/(^0?[1][358][0-9]{9}$)/",
		"alertText":"* 请输入有效的手机号码."},	
	"email":{
		"regex":"/^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/",
		"alertText":"* 请输入有效的邮件地址."},	
	"date":{
        "regex":"/^(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29)$/",
        "alertText":"* 请输入有效的日期,如:2008-08-08."},
	"ip":{
        "regex":"/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/",
       	"alertText":"* 请输入有效的IP."},
	"chinese":{
		"regex":"/^[\u4e00-\u9fa5]+$/",
		"alertText":"* 请输入中文."},
	"url":{
		"regex":"/^[a-zA-z]:\\/\\/[^s]$/",
		"alertText":"* 请输入有效的网址."},
	"zipcode":{
		"regex":"/^[1-9]\d{5}$/",
		"alertText":"* 请输入有效的邮政编码."},
	"onlyNumber":{
		"regex":"/^[0-9]+$/",
		"alertText":"* 请输入数字."},
	"integer":{
		"regex":"/^(((-|\\+)?[1-9]*[1-9][0-9]*)|[0])$/",
		"alertText":"* 请输入整数."},
	"positiveInteger":{
		"regex":"/^\\+?[1-9]*[1-9][0-9]*$/",
		"alertText":"* 请输入正整数(自然数)."},
	"negativeInteger":{
		"regex":"/^-[0-9]*[1-9][0-9]*$/",
		"alertText":"* 请输入负整数."},
	"nonPositiveInteger":{
		"regex":"/^((-\\d+)|(0+))$/",
		"alertText":"* 请输入非正整数（负整数 + 0）."},
	"nonNegativeInteger":{
		"regex":"/^\\d+$/",
		"alertText":"* 请输入非负整数（正整数 + 0）."},
	"decimalNum":{
		"regex":"/^(-?[1-9]*[1-9][0-9]*|[0])(\\.\\d+)?$/",
		"alertText":"* 请输入整数或小数."},
	"onlyLetter":{
		"regex":"/^[a-zA-Z]+$/",
		"alertText":"* 请输入英文字母."},
	"noSpecialCaracters":{
		"regex":"/^[0-9a-zA-Z]+$/",
		"alertText":"* 请输入英文字母和数字."},
	"idCard":{
		"regex":"none",
		"alertText1":"* 身份证号码位数不对.",		
		"alertText2":"* 身份证含有非法字符.",		
		"alertText3":"* 身份证号码校验码错误.",		
		"alertText4":"* 身份证地区非法.",		
		"alertText5":"* 身份证出生日期不对."},		
	"qq":{
		"regex":"/^[1-9]\d{4,9}$/",
		"alertText":"* 请输入有效的QQ号码."},
	"maxSelected":{
		"regex":"none",
		"alertText":"* 最多选择 ",
		"alertText2":" 项."},	
	"minSelected":{
		"regex":"none",
		"alertText":"* 至少选择 ",
		"alertText2":" 项."},	
	"confirm":{
		"regex":"none",
		"alertText":"* 两次输入不一致,请重新输入."}	
					
};

//身份证校验   
function isIdCard(idNum){
		//idNum = idNum.toUpperCase();
         //身份号码位数及格式检验   
         var re;   
         var len = idNum.length;   
         //身份证位数检验   
         if(len != 15 && len != 18){   
             //return errors[1];
			 return allRules["idCard"].alertText1;   
         }else if(len == 15){   
             re = new RegExp(/^(\d{6})()?(\d{2})(\d{2})(\d{2})(\d{3})$/);   
         }else{   
             re = new RegExp(/^(\d{6})()?(\d{4})(\d{2})(\d{2})(\d{3})([0-9xX])$/);   
         }
		 var area={11:"北京",12:"天津",13:"河北",14:"山西",
		 			15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",
					32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",
					37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",
					45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",
					53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",
					64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",
					91:"国外"}
        var idcard_array = new Array();   
        idcard_array = idNum.split("");
        //地区检验   
        if(area[parseInt(idNum.substr(0,2))]==null) {
			//return errors[4];
			return allRules["idCard"].alertText4;
        }   
      //出生日期正确性检验   
      var a = idNum.match(re);   
      if (a != null){  
            if (len==15){  
                 var DD = new Date("19"+a[3]+"/"+a[4]+"/"+a[5]);   
                 var flag = DD.getYear()==a[3]&&(DD.getMonth()+1)==a[4]&&DD.getDate()==a[5];   
            }else if(len == 18){   
                 var DD = new Date(a[3]+"/"+a[4]+"/"+a[5]);   
                 var flag = DD.getFullYear()==a[3]&&(DD.getMonth()+1)==a[4]&&DD.getDate()==a[5];   
            }   
            if (!flag) {   
                 //return "身份证出生日期不对！";
				 return allRules["idCard"].alertText5;
            }                        
          
            //检验校验位   
            if(len == 18){
	              S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7  
	              + (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9  
	              + (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10  
	              + (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5  
	              + (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8  
	              + (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4  
	              + (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2  
	              + parseInt(idcard_array[7]) * 1
	              + parseInt(idcard_array[8]) * 6
	              + parseInt(idcard_array[9]) * 3 ;   
	               
	              Y = S % 11;   
	              M = "F";   
	              JYM = "10X98765432";   
	              M = JYM.substr(Y,1);//判断校验位   
	              //检测ID的校验位   
	              if(M != idcard_array[17]){   
	                  //return errors[3];
					  return allRules["idCard"].alertText3;  
	              }   
             }   
             
	} else {
		//return errors[2];
		 return allRules["idCard"].alertText2;  
    }   
   return "";   
}